package com.xh.car.util;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;


/**
 * @Author PangJunjie
 * @Date 2024/4/24/024
 */
//@ControllerAdvice
//@ResponseBody
@RestControllerAdvice
@Slf4j
public class AppExceptionHandler {
    @ExceptionHandler(IllegalStateException.class)
    public R handlerIllegalStateException(IllegalStateException e) {
        log.info(e.getMessage());
        return R.error(e.getMessage());
    }


    @ExceptionHandler(RTException.class)
    public R handlerRTException(RTException e) {
        log.info(e.getMessage());
        return R.error(e.getCode(), e.getMsg());
    }

    @ExceptionHandler(Exception.class)
    public R handlerException(Exception e) {
        log.info(e.getMessage());
        return R.error(e.getMessage());
    }
}
